package chapter19.homework1;

public class SkyTelevision implements Tv {

    private Object[] objects = {"CCTV"};

    public TVIterator createIterator() {
        return new SkyIterator();
    }
    private class SkyIterator implements TVIterator {
        private int currentIndex = 0;

        @Override
        public void setChannel(int i) {
            currentIndex = i;
        }

        @Override
        public void next() {
            if(currentIndex < objects.length) {
                currentIndex++;
            }
        }

        @Override
        public void previous() {
            if (currentIndex > 0){
                currentIndex--;
            }
        }

        @Override
        public boolean isLast() {
            return currentIndex == objects.length;
        }

        @Override
        public Object currentChannel() {
            return objects[currentIndex];
        }

        @Override
        public boolean isFirst() {
            return currentIndex == 0;
        }
    }
}
